package com.dong.controller;

import com.dong.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Controller
//@RequestMapping("/test")
public class HelloController {

    @RequestMapping("/hello")
    public String hello(){
        System.out.println("请求到控制器");
        return "redirect:/hello2";

    }
    @ResponseBody
    @RequestMapping("/hello1")
    public String hello1(Model model){
       model.addAttribute("name","林东松");

        return "tes";
    }
    @RequestMapping("/hello2")
        public String hello2(Model model, HttpSession session){
          model.addAttribute("msg","林生");
          session.setAttribute("username","林松");
          model.addAttribute("day",new Date());
          List<User> list = new ArrayList<>();
          list.add(new User("admin1","11"));
          list.add(new User("admin2","111"));
          list.add(new User("admin3","111"));
          list.add(new User("admin4","111"));
          model.addAttribute("user",list);
        return "test";
        }

}
